﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Sach.aspx.cs" Inherits="Sach" %>

<asp:Content ID="Content4" ContentPlaceHolderID="Menu" Runat="Server">
    <li  ><a href="Default.aspx">Trang Chủ</a></li>
    <li id="currect"><a href="Sach.aspx">Sách</a></li>
    <li><a href="Ebook.aspx">Ebook</a></li>
    <li ><a href="HoaDon.aspx">Hóa Đơn</a></li>
    <li><a href="KhachHang.aspx">Khách Hàng</a></li>
    <li><a href="WebService.aspx">Webservice</a></li>
    <li><a href="LienHe.aspx">Liên Hệ</a></li>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentTitle" Runat="Server">    
    QUẢN LÝ SÁCH
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentDescription" Runat="Server">    
    Quản lý sách: Thêm sách, xóa sách, thay đổi thông tin sách và tìm kiếm sách.
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContain" Runat="Server">
<h4>Thêm sách mới</h4>
<hr/>
    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
        DataKeyNames="MaSach" DataSourceID="SqlDataSourceThemSach" DefaultMode="Insert" 
        Height="50px" Width="397px">
        <Fields>
            <asp:BoundField DataField="MaSach" HeaderText="Mã Sách" InsertVisible="False" 
                ReadOnly="True" SortExpression="MaSach" />
            <asp:BoundField DataField="TenSach" HeaderText="Tên Sách" 
                SortExpression="TenSach" />
            <asp:BoundField DataField="GiaSach" HeaderText="Giá Sách" 
                SortExpression="GiaSach" />
            <asp:BoundField DataField="TacGia" HeaderText="Tác Giả" 
                SortExpression="TacGia" />
            <asp:BoundField DataField="NhaXuatBang" HeaderText="Nhà Xuất Bản" 
                SortExpression="NhaXuatBang" />
            <asp:BoundField DataField="TomTacNoiDung" HeaderText="Tóm Tắc" 
                SortExpression="TomTacNoiDung" />
            <asp:BoundField DataField="MaTheLoaiSach" HeaderText="Mã Thể Loại" 
                SortExpression="MaTheLoaiSach" />
            <asp:BoundField DataField="MaEbook" HeaderText="Mã Ebook" 
                SortExpression="MaEbook" />
            <asp:BoundField DataField="SoLuongCon" HeaderText="Số Lượng Còn" 
                SortExpression="SoLuongCon" />
            <asp:BoundField DataField="SoLuongBan" HeaderText="Số Lượng Bán" 
                SortExpression="SoLuongBan" />
            <asp:BoundField DataField="NgayXuatBang" HeaderText="Ngày Xuất Bản" 
                SortExpression="NgayXuatBang" />
            <asp:BoundField DataField="AnhBia" HeaderText="Bìa Sách" 
                SortExpression="AnhBia" />
            <asp:CommandField ShowInsertButton="True"  InsertText="[Thêm] " CancelText=" [Hủy]"/>
        </Fields>
    </asp:DetailsView>
    <asp:SqlDataSource ID="SqlDataSourceThemSach" runat="server" 
        ConnectionString="<%$ ConnectionStrings:PublisherDBConnectionString %>" 
        DeleteCommand="DELETE FROM [Sach] WHERE [MaSach] = @MaSach" 
        InsertCommand="INSERT INTO [Sach] ([TenSach], [GiaSach], [TacGia], [NhaXuatBang], [TomTacNoiDung], [MaTheLoaiSach], [SoLuongCon], [SoLuongBan], [NgayXuatBang], [AnhBia]) VALUES (@TenSach, @GiaSach, @TacGia, @NhaXuatBang, @TomTacNoiDung, @MaTheLoaiSach, @SoLuongCon, @SoLuongBan, @NgayXuatBang, @AnhBia)" 
        SelectCommand="SELECT * FROM [Sach]" 
        UpdateCommand="UPDATE [Sach] SET [TenSach] = @TenSach, [GiaSach] = @GiaSach, [TacGia] = @TacGia, [NhaXuatBang] = @NhaXuatBang, [TomTacNoiDung] = @TomTacNoiDung, [MaTheLoaiSach] = @MaTheLoaiSach, [MaEbook] = @MaEbook, [SoLuongCon] = @SoLuongCon, [SoLuongBan] = @SoLuongBan, [NgayXuatBang] = @NgayXuatBang, [AnhBia] = @AnhBia WHERE [MaSach] = @MaSach">
        <DeleteParameters>
            <asp:Parameter Name="MaSach" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="TenSach" Type="String" />
            <asp:Parameter Name="GiaSach" Type="Decimal" />
            <asp:Parameter Name="TacGia" Type="String" />
            <asp:Parameter Name="NhaXuatBang" Type="String" />
            <asp:Parameter Name="TomTacNoiDung" Type="String" />
            <asp:Parameter Name="MaTheLoaiSach" Type="Int32" />
            <asp:Parameter Name="MaEbook" Type="Int32" />
            <asp:Parameter Name="SoLuongCon" Type="Int32" />
            <asp:Parameter Name="SoLuongBan" Type="Int32" />
            <asp:Parameter DbType="Date" Name="NgayXuatBang" />
            <asp:Parameter Name="AnhBia" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="TenSach" Type="String" />
            <asp:Parameter Name="GiaSach" Type="Decimal" />
            <asp:Parameter Name="TacGia" Type="String" />
            <asp:Parameter Name="NhaXuatBang" Type="String" />
            <asp:Parameter Name="TomTacNoiDung" Type="String" />
            <asp:Parameter Name="MaTheLoaiSach" Type="Int32" />
            <asp:Parameter Name="MaEbook" Type="Int32" />
            <asp:Parameter Name="SoLuongCon" Type="Int32" />
            <asp:Parameter Name="SoLuongBan" Type="Int32" />
            <asp:Parameter DbType="Date" Name="NgayXuatBang" />
            <asp:Parameter Name="AnhBia" Type="String" />
            <asp:Parameter Name="MaSach" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>

<br/>
<h4>Danh sách các cuốn sách</h4>
<hr/>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
    DataKeyNames="MaSach" DataSourceID="SqlDataSourceDSSach" Width="1005px" 
        Font-Size="Small" BackColor="White" BorderColor="#999999" 
    BorderStyle="Solid" BorderWidth="1px" CellPadding="3" 
    ForeColor="Black" AllowPaging="True" GridLines="Vertical" CssClass="pretty" 
        onrowdatabound="GridView1_RowDataBound">
        <AlternatingRowStyle BackColor="#CCCCCC" />
    <Columns>
        <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
        <asp:BoundField DataField="MaSach" HeaderText="MaSach" InsertVisible="False" 
            ReadOnly="True" SortExpression="MaSach" />
        <asp:BoundField DataField="TenSach" HeaderText="TenSach" 
            SortExpression="TenSach" />
        <asp:BoundField DataField="GiaSach" HeaderText="GiaSach" 
            SortExpression="GiaSach" />
        <asp:BoundField DataField="TacGia" HeaderText="TacGia" 
            SortExpression="TacGia" />
        <asp:BoundField DataField="NhaXuatBang" HeaderText="NhaXuatBang" 
            SortExpression="NhaXuatBang" />
        <asp:BoundField DataField="TenTheLoaiSach" HeaderText="TenTheLoaiSach" 
            SortExpression="TenTheLoaiSach" />
        <asp:BoundField DataField="SoLuongCon" HeaderText="SoLuongCon" 
            SortExpression="SoLuongCon" />
        <asp:BoundField DataField="SoLuongBan" HeaderText="SoLuongBan" 
            SortExpression="SoLuongBan" />
        <asp:BoundField DataField="NgayXuatBang" HeaderText="NgayXuatBang" 
            SortExpression="NgayXuatBang" />
        <asp:BoundField DataField="AnhBia" HeaderText="AnhBia" 
            SortExpression="AnhBia" />
    </Columns>
        <FooterStyle BackColor="#CCCCCC" />
        <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
        <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
        <SortedAscendingCellStyle BackColor="#F1F1F1" />
        <SortedAscendingHeaderStyle BackColor="#808080" />
        <SortedDescendingCellStyle BackColor="#CAC9C9" />
        <SortedDescendingHeaderStyle BackColor="#383838" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSourceDSSach" runat="server" 
    ConnectionString="<%$ ConnectionStrings:PublisherDBConnectionString %>" 
    InsertCommand="INSERT INTO [Sach] ([TenSach], [GiaSach], [TacGia], [NhaXuatBang], [TomTacNoiDung], [MaTheLoaiSach], [MaEbook], [SoLuongCon], [SoLuongBan], [NgayXuatBang], [AnhBia]) VALUES (@TenSach, @GiaSach, @TacGia, @NhaXuatBang, @TomTacNoiDung, @MaTheLoaiSach, @MaEbook, @SoLuongCon, @SoLuongBan, @NgayXuatBang, @AnhBia)" 
    SelectCommand="SELECT Sach.MaSach, Sach.TenSach, Sach.GiaSach, Sach.TacGia, Sach.NhaXuatBang, TheLoaiSach.TenTheLoaiSach, Sach.SoLuongCon, Sach.SoLuongBan, Sach.NgayXuatBang, Sach.AnhBia FROM Sach INNER JOIN TheLoaiSach ON Sach.MaTheLoaiSach = TheLoaiSach.MaTheLoaiSach" 
        DeleteCommand="DELETE FROM [Sach] WHERE [MaSach] = @MaSach" 
        UpdateCommand="UPDATE [Sach] SET [TenSach] = @TenSach, [GiaSach] = @GiaSach, [TacGia] = @TacGia, [NhaXuatBang] = @NhaXuatBang, [TomTacNoiDung] = @TomTacNoiDung, [MaEbook] = @MaEbook, [SoLuongCon] = @SoLuongCon, [SoLuongBan] = @SoLuongBan, [NgayXuatBang] = @NgayXuatBang, [AnhBia] = @AnhBia WHERE [MaSach] = @MaSach">
    <DeleteParameters>
        <asp:Parameter Name="MaSach" Type="Int32" />
    </DeleteParameters>
    <InsertParameters>
        <asp:Parameter Name="TenSach" Type="String" />
        <asp:Parameter Name="GiaSach" Type="Decimal" />
        <asp:Parameter Name="TacGia" Type="String" />
        <asp:Parameter Name="NhaXuatBang" Type="String" />
        <asp:Parameter Name="TomTacNoiDung" Type="String" />
        <asp:Parameter Name="MaTheLoaiSach" Type="Int32" />
        <asp:Parameter Name="MaEbook" Type="Int32" />
        <asp:Parameter Name="SoLuongCon" Type="Int32" />
        <asp:Parameter Name="SoLuongBan" Type="Int32" />
        <asp:Parameter DbType="Date" Name="NgayXuatBang" />
        <asp:Parameter Name="AnhBia" Type="String" />
    </InsertParameters>
    <UpdateParameters>
        <asp:Parameter Name="TenSach" Type="String" />
        <asp:Parameter Name="GiaSach" Type="Decimal" />
        <asp:Parameter Name="TacGia" Type="String" />
        <asp:Parameter Name="NhaXuatBang" Type="String" />
        <asp:Parameter Name="TomTacNoiDung" Type="String" />
        <asp:Parameter Name="MaTheLoaiSach" Type="Int32" />
        <asp:Parameter Name="MaEbook" Type="Int32" />
        <asp:Parameter Name="SoLuongCon" Type="Int32" />
        <asp:Parameter Name="SoLuongBan" Type="Int32" />
        <asp:Parameter DbType="Date" Name="NgayXuatBang" />
        <asp:Parameter Name="AnhBia" Type="String" />
        <asp:Parameter Name="MaSach" Type="Int32" />
    </UpdateParameters>
</asp:SqlDataSource>
</asp:Content>

